/*
 * @Author: LiuHaiL 18655112670@139.com
 * @Date: 2023-07-21 14:21:32
 * @LastEditors: LiuHaiL 18655112670@139.com
 * @LastEditTime: 2023-07-24 17:24:57
 * @FilePath: \general-admin\src\api\backend\index.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import createAxios from '/@/utils/axios'
import { useAdminInfo } from '/@/stores/adminInfo'

const controllerUrl = '/admin/v1/'

export function index() {
    return createAxios({
        url: controllerUrl + 'index',
        method: 'get',
    })
}
/**
 * 登录
 * @param method  
 * @param params 
 * @returns 
 */
export function login(method: 'get' | 'post', params: object = {}): ApiPromise {
    return createAxios({
        url: controllerUrl + 'login',
        data: params,
        method: method,
    }) as ApiPromise
}

/**
 * 注销
 * @returns 
 */
export function logout() {
    const adminInfo = useAdminInfo()
    return createAxios({
        url: controllerUrl + 'logout',
        method: 'POST',
        data: {
            refresh_token: adminInfo.getToken('refresh'),
        },
    })
}



export function auditShop(method: 'get' | 'post', params: object = {}): ApiPromise {
    return createAxios({
        url: controllerUrl + 'commodity/audit/examine',
        data: params,
        method: method,
    }) as ApiPromise
}

export function withdrawalDetail(id: string) {
    return createAxios({
        url: controllerUrl + 'user/withdrawal/detail',
        method: 'get',
        params: {
            id: id,
        },
    })
}


//售后审核
export function auditWithdrawal(params: object = {}) {
    return createAxios(
        {
            url: controllerUrl + 'user/withdrawal/auth',
            method: 'POST',
            data: params,
        },
        {
            showSuccessMessage: true,
        }
    )
}

//打款按钮
export function paymentWithdrawal(params: object = {}) {
    return createAxios(
        {
            url: controllerUrl + 'user/withdrawal/payment',
            method: 'POST',
            data: params,
        },
        {
            showSuccessMessage: true,
        }
    )
}

